
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">
	/*树形表格设置*/
	var setting = {
			check: {
				enable: true,
				chkStyle: "radio",
				radioType: "all"
			},
			view: {
				dblClickExpand: false
			},
			
			  data: {
				  key :{
						name:"columnName",
					},
		    	 simpleData: {//简单数据模式
			     	 enable:true,
			      	 idKey: "id",
			     	 pIdKey: "parentId",
			    	 rootPId: null
		  	  }
		 	 },
			callback: {
				onClick: onClick,
				onCheck: onCheck
			}
	};
	
	
	
	function onClick(e, treeId, treeNode) {
		e.preventDefault();
		var zTree = $.fn.zTree.getZTreeObj("permissionZtree");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}	
	
	function onCheck(e, treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("permissionZtree"),
			nodes = zTree.getCheckedNodes(true),
			v = "";
			pId = "";
			for (var i=0, l=nodes.length; i<l; i++) {
				v += nodes[i].columnName + ",";
				pId += nodes[i].id + ",";
			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);
			if (pId.length > 0 ) pId = pId.substring(0, pId.length-1);
			var parentName = $("#parent_name");
			var parentId = $("#parentId");
			parentName.attr("value", v);
			parentId.attr("value",pId)
			hideMenu();
	}
	
	function showPermissonList(){
		var parentName = $("#parent_name");
		var offset = $("#parent_name").offset();
		$("#tree_content").slideDown("fast");
		 $("body").bind("mousedown", onBodyDown);
	}
	
	function hideMenu() {
			$("#tree_content").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
	}
	
 	function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "parent_name" || event.target.id == "tree_content" || $(event.target).parents("#tree_content").length>0)) {
				hideMenu();
			}
	}

	function onLoadZTree(){
	     var t = $("#permissionZtree");
	  	 t = $.fn.zTree.init(t, setting, ${treeNodes}).expandAll(true); 
	} 
	
	function setAttr(){
	 if("add"==$('#op').val()){
			$('#is_used').attr("disabled","disabled");
		}else{
			$('#is_used').removeAttr();
		}	
	}
	$(document).ready(function(){
		onLoadZTree();
		setAttr();	
	
	});
</script>
<script type="text/javascript">
    window.CKEDITOR_BASEPATH = '${ctx}/resources/js/ckeditor/';
</script> 
<script type="text/javascript" src="${ctx}/resources/js/ckeditor/ckeditor.js"></script>

<div class="bjui-pageContent">
    <form action="${ctx}/sys/sysArticleAction/doSave" class="ajaxForm" data-toggle="validate" enctype="multipart/form-data">
        <input type="hidden" name="op" id="j_dialog_op" value="${param.op}${op}">
        <input type="hidden" name="id" id="j_dialog_id" value="${article.id}">
        <input type="hidden" name="classOne" id="classOne" value="${article.classOne}">
        <input type="hidden" name="content" id="content" value="">
        <c:if test="${!empty role}">
	        <input type="hidden" name="status" id="j_dialog_op" value="${article.status}">
        </c:if>
        <table class="table table-condensed table-hover">
            <tbody>
                <tr>
                    <td colspan="2" align="center" valign="middle"><h4>${title}</h4></td>
                </tr>
                <tr style="height: 30px;">
                    <td>
                        <label for="name" class="control-label x90">文章标题：</label>
                        <input class="" id="title" type="text" name="title"  value="${article.title}"  data-rule="required;"/>
                    </td>
                </tr>
                <tr>
                    <td>
                    <label for="name" class="control-label x90">所属栏目：</label>
                        <input class="m_readonly" id="parent_name" type="text" name="classOne" readonly value="${article.classOneName}" onclick="showPermissonList()" data-rule="required;"/>
						<div id="tree_content" class="m_ztree_content" style="display: none; position: absolute;">
							<ul id="permissionZtree" class="ztree" style="margin-top: 0; width: 160px;"></ul>
						</div>
					</td>
				</tr>
				 <tr>
                  <td>
               			<label for="name" class="control-label x90">文章类型：</label>
                        <select id="couponType" name="articleType" data-toggle="selectpicker" >
							<c:forEach items="${articleType}" var="c">
								<c:choose>
									<c:when test="${article.articleType==c.id}">
										<option value="${c.id}" selected="selected">${c.codeName}</option>
									</c:when>
									<c:otherwise>
										<option value="${c.id}">${c.codeName}</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
					    </select>
                    </td>
               </tr>
                <tr>
                    <td>
                        <label for="name" class="control-label x90">关键词：</label>
                        <input class="" id="keyWords" type="text" name="keyWords"  value="${article.keyWords}"/>
                    </td>
                </tr>
                 <tr style="height: 30px;">
                  <td>
                        <label for="name" class="control-label x90">描述：</label>
                        <input class="" id="description" type="text" name="description"  value="${article.description}"/>
                 </tr>
                 <tr style="height: 30px;">
                    <td colspan="2">
                        <label for="description" class="float:left;">文章内容：</label>
                        <textarea name="temp_content" id="temp_content" rows="4" cols="58" >${article.content}</textarea>
						<script type="text/javascript"> 
						var  id=$(" #j_dialog_id").val();
						console.log("id的值"+id);
                    	var editor =CKEDITOR.replace("temp_content", {
                    	 	filebrowserImageUploadUrl : '/zpj/sys/sysArticleAction/doSaveImage',
                    	    language: 'zh-cn',
                    	    uiColor: '#9AB8F3',    	 
                    	})
                    	var data = CKEDITOR.instances.temp_content.getData();
                    	$("#content").val(data);
                    	editor.on( 'change', function( evt ) {
                    	    // getData() returns CKEditor's HTML content.
                    	    $("#content").val(evt.editor.getData());
                    	    
                    	});
                   
                    	</script>                    
                    </td> 
                 </tr>
                    <tr style="height: 30px;">
                    <td>
                        <label for="name" class="control-label x90">附件地址：</label>
                         <input class="" id="downloadUrl" type="text" name="downloadUrl" readonly="readonly" value="${article.downloadUrl}" />
						<input type="file" name="file1"  style="width: 50%;" >
                    </td>
                </tr>
                <tr style="height: 30px;">
                	<td>
                        <label for="name" class="control-label x90">视频地址：</label>
                        <input class="" id="videoUrl" type="text" name="videoUrl" readonly="readonly" value="${article.videoUrl}" />
						<input type="file" name="file2" accept="video/*" style="width: 40%;" >
                    </td>      
                  </tr>
                  <tr style="height: 30px;">
                    <td>
                        <label for="name" class="control-label x90">图片地址：</label>
                        <input class="" id="themeImageUrl" type="text" name="themeImageUrl" readonly="readonly" value="${article.themeImageUrl}" />
						<input type="file" name="file3" accept="image/*" style="width: 40%;" >
                    </td>
                    
                 </tr>
               <tr style="height: 30px;">
                    <td>
					 	<label for="name" class="control-label x90">阅读次数：</label>
                        <input class="" id="readCount" type="text" name="readCount" value="${article.readCount}" />
                        <label for="name" class="control-label x90">是否置顶：</label>
                        	<select id="j_dialog_type_id" name="isTop" data-toggle="selectpicker">
                        	<c:forEach items="${code}" var="c">
								<c:choose>
									<c:when test="${article.isTop==c.codeValue}">
										<option value="${c.codeValue}" selected="selected">${c.codeName}</option>
									</c:when>
									<c:otherwise>
										<option value="${c.codeValue}">${c.codeName}</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
							</select>
                    </td>
               </tr>
               <tr style="height: 30px;">
                    <td>
                    	<label for="name" class="control-label x90">点赞次数：</label>
                        <input class="" id="praiseCount" type="text" name="praiseCount"  value="${article.praiseCount}"/>
                        <label for="name" class="control-label x90">是否更新：</label>
                        	<select id="j_dialog_type_id" name="isNewest" data-toggle="selectpicker">	
                        	<c:forEach items="${code}" var="c">
								<c:choose>
									<c:when test="${article.isNewest==c.codeValue}">
										<option value="${c.codeValue}" selected="selected">${c.codeName}</option>
									</c:when>
									<c:otherwise>
										<option value="${c.codeValue}">${c.codeName}</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
							</select>
                    </td>
                </tr>
                  <tr style="height: 30px;">
                    <td>

                        <label for="name"  class="control-label x90">踩踏次数：</label>
                        <input class="" id="stepCount" type="text" name="stepCount" value="${article.stepCount}" />
                    </td>
                </tr>			
                 <tr style="height: 30px;">
                	<td colspan="2">
                        <label for="description" class="control-label x90">备注1：</label>
                        <textarea name="remarkOne" id="remarkOne" rows="5" cols="58">${article.remarkOne}</textarea>
                     </td>   
   			</tr>
    			<tr> 
    				 <td>	
                        <label for="description" class="control-label x90">备注2：</label>
                        <textarea name="remarkTwo" id="remarkTwo" rows="5" cols="58" >${article.remarkTwo}</textarea>
                    </td>
                </tr>
           
                  
            </tbody>
        </table>
    </form>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
        <li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
    </ul>
</div>

